package cn.le.studyEnum;


import java.util.Random;

/**
 * enum实现接口
 */
public enum CartoonCharacter implements Generator<CartoonCharacter>{

    SLAPPY,SPANKY,PUMCHY;

    private Random rand = new Random(47);

    public CartoonCharacter next()
    {
        return values()[rand.nextInt(values().length)];
    }
}
interface Generator<T>{

    public T next();

}


class EnumImplementaton{

    public static <T> void printNext(Generator<T> rg)
    {
        System.out.print(rg.next()+". ");
    }

    public static void main(String[] args) {
        CartoonCharacter cc = CartoonCharacter.PUMCHY;
        for (int i = 0, length = 5; i < length; i++) {
            printNext(cc);
        }
    }

}